import React, { Component } from 'react';

class TabContent extends Component {
  getTabPane () {
    const {classPrefix, activeIndex, panels} = this.props;
    return panels && panels.map(panel => {
      const order = panel.props.order;
      const isActive = activeIndex === order;
      return React.cloneElement(panel, {
        classPrefix,
        isActive,
        key: `tabcontent-${order}`,
        children: panel.props.children
      });
    });
  }
  render() {
    return (
      <div className="tabs-content">
        {
          this.getTabPane()
        }
      </div>
    );
  }

}

export default TabContent;
